package org.ruanjj.linkedlist;

import java.util.ArrayList;

public class Util {
    public static String listVal(ListNode l){
        StringBuilder stringBuilder = new StringBuilder();
        while(null != l){
            stringBuilder.append(l.val+"");
            l = l.next;
        }
        return stringBuilder.toString().trim();
    }

    public static ListNode createListNode(ArrayList<Integer> list){
        ListNode res = new ListNode(0);
        ListNode cur = res;
        if(list.size()>0){
            for(int i = 0; i < list.size(); i++){
                cur.next = new ListNode(list.get(i));
                cur = cur.next;
            }
        }
        return res.next;
    }
}
